﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MagistrAPI.Enums;

namespace MagistrAPI.MathModel
{
    public static class CharacteristicEquations
    {
        private static Dictionary<Characteristics, Delegate> _characteristics;

        public static Dictionary<Characteristics, Delegate> Characteristics
        {
            get
            {
                return _characteristics ?? (_characteristics = new Dictionary<Characteristics, Delegate>(11)
                                                                   {
                                                                         {Enums.Characteristics.V, new Func<double[], double>(V)},
                                                                         {Enums.Characteristics.H, new Func<double[], double>(H)},
                                                                          {Enums.Characteristics.Al, new Func<double[], double>(Al)}
                                                                   });
            }
        }

        private static double Al(double[] arg)
        {
            double x = arg[0];
            double y = arg[1];
            double z = arg[2];
            double vX = arg[3];
            double vY = arg[4];
            double vZ = arg[5];
            double lX = arg[9];
            double lY = arg[10];
            double lZ = arg[11];
            double mX = arg[12];
            double mY = arg[13];
            double mZ = arg[14];
            double nX = arg[15];
            double nY = arg[16];
            double nZ = arg[17];
            return MathModelFunc.ααnb(x, y, z, vX, vY, vZ, lX, lY, lZ, mX, mY, mZ, nX, nY, nZ);
        }

        private static double H(double[] arg)
        {
            double x = arg[0];
            double y = arg[1];
            double z = arg[2];
            return MathModelFunc.H(x, y, z);
        }

        private static double V(double[] arg)
        {
            double x = arg[0];
            double y = arg[1];
            double z = arg[2];
            double vX = arg[3];
            double vY = arg[4];
            double vZ = arg[5];
            double[] rezult = MathModelFunc.Vbu(x, y, z, vX, vY, vZ);
            return MathModelFunc.AbsV(rezult[0], rezult[1], rezult[2]);
        }
    }
}
